import React, {Component} from 'react'
import {
    StyleSheet,
    View,
    Text,
    Button
} from 'react-native'

import { connect } from "react-redux";
import { onThemeChange } from "../store/actions"

class DetailPage extends Component{
    constructor(props) {
        super(props)
        console.log(props)
    }
    
    render(){
        return (
            <View>
                <Text>DetailPage</Text>
                <Text>{this.props.theme}</Text>
                <Button title="改变redux，哈哈" onPress={() => {
                    this.props.onThemeChange("red")
                }}></Button>
            </View>
        )
    }
}

const style = StyleSheet.create({
    
})

const mapStateToProps = state => ({
    theme: state.app.theme
})

const mapDispatchToProps = dispatch => ({
    onThemeChange: theme => dispatch(onThemeChange(theme))
})

export default connect(mapStateToProps, mapDispatchToProps)(DetailPage)